package choose.practice;

import java.util.Random;
import java.util.Scanner;

public class practice01 {
    public static void main(String[] args) {
        //practice();
        //practice02(34);
        //practice03(7);
        guessNumber();

    }
    // 过7操作
    public static void practice(){
        for (int i = 1; i <= 100; i++) {
            if(i%10==7 || i/10%10 ==7 || i%7==0){
                System.out.println("过");
                continue;
            }
            System.out.println(i);
        }
    }
    // 求平方根
    public static void practice02(int number){
        for (int i = 1; i <= number; i++) {
            if(i*i == number){
                System.out.println(i+"就是"+number+"平方根");
            } else if (i * i > number) {
                System.out.println((i-1)+"就是"+number+"的整数部分");
                break;
            }

        }
    }
    // 求质数
    public static void practice03(int number){
        for (int i = 2; i < number; i++) {
            if(number % i ==0){
                System.out.println("不是质数");
                break;
            }
        }
        System.out.println("质数");
        // 优化就是有个特点就是只需要去搞一半就可以了，另一半不需要考虑
    }
    // guessNumber
    public static void guessNumber(){
        Random rd = new Random();
        int i = rd.nextInt(1, 101);
        System.out.println(i);
        Scanner sc = new Scanner(System.in);
        while (true){
            int number = sc.nextInt();
            if (number<i){
                System.out.println("输入小了");
            }else if (number>i){
                System.out.println("输入大了");
            }else {
                System.out.println("猜对了");
                break;
            }
        }

    }

}
